package com.lynn.activiti.rest;

import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.task.Task;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description:
 * @Date: 2019-11-17 19:33
 * @Auther: lynn
 */
@RestController
public class HelloController {
    @Autowired
    RuntimeService runtimeService;

    @Autowired
    TaskService taskService;


    @GetMapping("/")
    String index() {
        return "hello world !";
    }


    @GetMapping("/hello")
    String hello() {
        String pid = runtimeService.startProcessInstanceByKey("myProcess_1").getId();
        Task task = taskService.createTaskQuery().processInstanceId(pid).singleResult();
        return "hello world spring boot...." + task.getId();
    }
}
